<%@ page language="java" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/view/jsp/admin/includes/taglibs.jsp"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<title>用户列表</title>
		<%@ include file="/WEB-INF/view/jsp/admin/includes/meta.jsp"%>
		<link type="text/css" rel="stylesheet" href="${ctx}/admin/css/admin.css" />
		<link href="${ctx}/widgets/extremecomponents/extremecomponents.css"
			type="text/css" rel="stylesheet" />
		<script type="text/javascript">
		function go(url)
		{
			window.location.href = url;
		}
		function deleData(url)
		{
			if(confirm("确定要删除吗？"))
			{
				window.location.href = url;
			}
		}
		function enalbed(url)
		{
			if(confirm("确定要进行此操作吗？"))
			{
				window.location.href = url;
			}
		}
		function subForm()
		{
			var objFrom = document.getElementById("searchFrom");
			if(objFrom)
			{
				objFrom.submit();
			}
			 
		}
	</script>
	</head>
	<body>
		<div class="mask">
			<div class="container">
				<h3>
					用户列表
				</h3>
				<div id="content">
					<!-- start user list -->
					<form action="${ctx}/admin/user!list.do" method="post"
						id="searchFrom">
						<table>
							<tr>
								<td>
									用户名:
									<input type="text" name="username" id="username"
										value="${username}" />
								</td>
								<td>
									邮箱:
									<input type="text" name="email" id="email"
										value="${email}" />
								</td>
								<td>
									昵称:
									<input type="text" name="nickName" id="nickName"
										value="${nickName}" />
								</td>
								<td>
									<input type="button" name="button" class="btn"
										onclick="subForm()" value="搜 索" />
								</td>
							</tr>
						</table>
					</form>
					<ec:table items="page.result" var="user" rowsDisplayed="10"
						autoIncludeParameters="true" retrieveRowsCallback="limit"
						action="${ctx}/admin/user.do">
						<ec:row highlightRow="true">
							<ec:column property="rowcount" cell="rowCount" sortable="false"
								title="序号" width="30" />
							<ec:column property="username" title="用户名" width="80">
								<c:if test="${user.username=='admin'}">
								${user.username}
								</c:if>
								<c:if test="${user.username!='admin'}">
									<a href="#"
										onclick="javascript:go('${ctx}/admin/user!edit.do?id=${user.id}');">${user.username}</a>
								</c:if>
							</ec:column>
							<ec:column property="nickName" title="昵称" width="80" />
							<ec:column property="email" title="邮箱" sortable="false" width="80" />
							<ec:column property="null" title="是否可用" width="30">
								<c:choose>
									<c:when test="${user.enabled==true}">
								是
							</c:when>
									<c:otherwise>
								否
							</c:otherwise>
								</c:choose>
							</ec:column>
							<ec:column property="null" title="是否锁定" width="30">
								<c:choose>
									<c:when test="${user.locked==true}">
								是
							</c:when>
									<c:otherwise>
								否
							</c:otherwise>
								</c:choose>
							</ec:column>
							<ec:column property="createdDate" title="注册日期" width="80"
								sortable="true" cell="date" format="yyyy-MM-dd" />
							<ec:column property="null" title="动作" sortable="false"
								viewsAllowed="html">
								<security:authorize ifAnyGranted="ROLE_ADMIN">
									<c:if test="${user.username!='admin'}">
										<a href="#" class="ref"
											onclick="javascript:go('${ctx}/admin/user!edit.do?id=${user.id}');">修改</a>
										<a href="#" class="ref"
											onclick="javascript:deleData('${ctx}/admin/user!delete.do?id=${user.id}');">删除</a>
										<c:choose>
											<c:when test="${user.enabled==true}">
												<a href="#" class="ref"
													onclick="javascript:enalbed('${ctx}/admin/user!enabled.do?id=${user.id}&enabled=false');">禁用</a>
											</c:when>
											<c:otherwise>
												<a href="#" class="ref"
													onclick="javascript:enalbed('${ctx}/admin/user!enabled.do?id=${user.id}&enabled=true');">解除</a>
											</c:otherwise>
										</c:choose>
									</c:if>
									<a href="#" class="ref"
										onclick="javascript:go('${ctx}/admin/user!resetView.do?id=${user.id}');">重设密码</a>
								</security:authorize>
							</ec:column>
						</ec:row>
					</ec:table>
					<!-- end user list -->
					<div id="footer" class="footer">
						<security:authorize ifAnyGranted="ROLE_ADMIN">
							<input type="button" class="btn"
								onclick="javascript:go('${ctx}/admin/user!edit.do?id=');"
								value='创建管理员' />
						</security:authorize>
					</div>
				</div>
			</div>
		</div>
	</body>
</html>
